/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.eventos.bc;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.eventos.be.DetalleMaterial;

/**
 *
 * @author Lizardo Rios
 */
@Stateless
public class DetallleMaterialFacade implements DetalleMaterialFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(DetalleMaterial detalleMaterial) {
        em.persist(detalleMaterial);
    }

    public void edit(DetalleMaterial detalleMaterial) {
        em.merge(detalleMaterial);
    }

    public void remove(DetalleMaterial detalleMaterial) {
        em.remove(em.merge(detalleMaterial));
    }

    public DetalleMaterial find(Object id) {
        return em.find(DetalleMaterial.class, id);
    }

    public List<DetalleMaterial> findAll() {
        return em.createQuery("select m from MaterialAcademico m ").getResultList();
    }

    public List<DetalleMaterial> listarDetalleXMaterial(Integer codigoMaterial) {
        return em.createQuery("select d from DetalleMaterial d where d.macCodigo.macCodigo = ?1")
                .setParameter(1, codigoMaterial)
                .getResultList();
    }
    
}

